package hhpoll.dao.hibernate;

import org.hibernate.SessionFactory;

import hhpoll.dao.UserDAO;
import hhpoll.domain.User;

public class HibernateUserDAO extends GenericHibernateDAO<User, Long> implements UserDAO {

    public HibernateUserDAO(SessionFactory sessionFactory) {
        super(sessionFactory);
    }

    public User findByEmail (String email) {
        return (User)this.sessionFactory.getCurrentSession()
                                        .createQuery("from User where email = :email")
                                        .setString("email", email)
                                        .uniqueResult();
    }

}
